package ControlLayer;
import java.util.ArrayList;

import ModelLayer.*;
import DBLayer.*;

public class CtrClothing {
	DBClothing dbC;
	Clothing clo;
	
	CtrClothing(){
		dbC = new DBClothing();
		clo = new Clothing();
	}
	
	public ArrayList<Clothing> getAll(){
		return dbC.getAll();
		
	}
	
	public Clothing searchByName(String name){
		return dbC.find(name) ;
		
	}
	
	public Clothing searchByID(int id){
		return dbC.find_byID(id);
		
	}
	
	public int delete(int Prid){
		return dbC.delete(Prid);
	}
	
	public int updateClothing(int Prid, String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int currentStock, int minStock, int sid, String colour, String size){
		Clothing clothing = new Clothing(Prid, name, purchasePrice, salesPrice, rentPrice, countryOfOrigin, currentStock, minStock, sid, colour, size);
		return dbC.update(clothing);
	}
	
	public int insert(String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int currentStock, int minStock, int sid, String colour, String size){
		Clothing clothing = new Clothing(-1, name, purchasePrice, salesPrice, rentPrice, countryOfOrigin, currentStock, minStock, sid, colour, size);
		int rc = -1;
		try{
			
			rc = dbC.insert(clothing);
			
		}catch(Exception e){
			System.out.println("Error with inserting a product");
		}
		return rc;
	}
	
	
}
